import { ClusterOutlined, WindowsOutlined, OrderedListOutlined, LineChartOutlined, SolutionOutlined, ScheduleOutlined, AppstoreOutlined, SettingOutlined } from '@ant-design/icons'; //图标
import { Layout, Menu, theme, MenuProps } from 'antd'; //ui
import { useState } from 'react';
import { useNavigate } from 'react-router-dom'; //函数路由必要的
import AdminAdd from '../../pages/admin/adminAdd';
import AdminList from '../../pages/admin/adminList';
import "./Left.css"
const { Header, Content, Footer, Sider } = Layout;
type MenuItem = Required<MenuProps>['items'][number];
function getItem(
  label: React.ReactNode,
  key: React.Key,
  icon?: React.ReactNode,
  children?: MenuItem[],
): MenuItem {
  return {
    key,
    icon,
    children,
    label,
  } as MenuItem;
}
const items: MenuItem[] = [
  getItem('首页', '/index/Visitorindex', <LineChartOutlined />),

  getItem('访客记录', 'su1', <OrderedListOutlined />, [
    getItem('访客列表', '/index/visitorList'),
    getItem('访客添加修改', '/index/visitorAdd'),
    getItem('负责人操作导入详细', '/index/visitorPrincipal')
  ]),
  getItem('部门管理', 'su3', <SolutionOutlined />, [
    getItem('部门列表', '/index/DepartmentList'),
    getItem('部门添加修改', '/index/DepartmentAddEdit')
  ]),
  getItem('管理员', 'su4', <WindowsOutlined />, [
    getItem('管理员列表', 'adminList'),
    getItem('管理员添加修改', 'adminAdd')
  ]),
  getItem('核销人员管理', 'su5', <ClusterOutlined />, [
    getItem('核销人员列表', '/index/reviewerList'),
    getItem('核销人员添加修改', '/index/reviewerAddEdit'),
    getItem('核销人员日志', '/index/reviewerLog')
  ]),
  getItem('审核日志', 'su6', <ScheduleOutlined />, [
    getItem('审核列表', '/index/ExcelList')
  ]),
  getItem('校园动态', 'su7', <AppstoreOutlined />, [
    getItem('校园动态列表', '/index/SchoolList'),
    getItem('校园动态添加修改', '/index/SchoolAdd')
  ]),
  getItem('系统设置', '/index/system', <SettingOutlined />),
];

const Left = (props:any) => {

  const navigate = useNavigate() //

  const [collapsed, setCollapsed] = useState(false);
  const {
    token: { colorBgContainer },
  } = theme.useToken();

  return (
    <Layout
      style={{
        minHeight: '100vh',
      }}
    >
      {/* 左边菜单栏 */}
      <Sider collapsible collapsed={collapsed} onCollapse={(value) => setCollapsed(value)}>
        <Menu theme="dark" defaultSelectedKeys={['1']} mode="inline" items={items} onSelect={(e) => {
          //  console.log('e', e.keyPath)
          navigate(e.keyPath[0])
          setTimeout(() => {
            let matche = JSON.parse(window.sessionStorage.getItem('matches') as any)
            props.setMatches(matche) //Home组件传过来的
        }, 200);
        }} />

      </Sider>
    </Layout>
  );
};
export default Left;